<template>
  <!--  <IndexChart v-if="indexStyle === 0"></IndexChart>-->
  <!--  <IndexDef v-if="indexStyle === 1"></IndexDef>-->
  <!--  <IndexBdc v-if="indexStyle == 2"></IndexBdc>-->
  <!--  <IndexTask v-if="indexStyle == 3"></IndexTask>-->
  <!--  <div style="width: 100%; text-align: right; margin-top: 20px">-->
  <div>
    <iframe :src="url" width="100%" height="1277px" frameborder="0"></iframe>
  </div>
  <!--    首页主题：-->
  <!--    <a-radio-group v-model:value="indexStyle">-->
  <!--      <a-radio :value="0">默认</a-radio>-->
  <!--      <a-radio :value="1">销量统计</a-radio>-->
  <!--      <a-radio :value="2">业务统计</a-radio>-->
  <!--      <a-radio :value="3">我的任务</a-radio>-->
  <!--    </a-radio-group>-->
  <!--  </div>-->
</template>
<script lang="ts" setup>
  import { onMounted, ref } from 'vue';
  import IndexDef from './homePage/IndexDef.vue';
  import IndexChart from './homePage/IndexChart.vue';
  import IndexBdc from './homePage/IndexBdc.vue';
  import IndexTask from './homePage/IndexTask.vue';
  const indexStyle = ref(0);
  import { useUserStore } from '@/store/modules/user';
  const userStore = useUserStore();
  const username = userStore.getUserInfo.username;
  const url = ref('');
  import { defHttp } from '@/utils/http/axios';
  onMounted(() => {
    // 获取今日日期并确保统一为字符串类型进行格式化
    const date = new Date();
    const year = date.getFullYear().toString();
    let month = (date.getMonth() + 1).toString();
    let day = date.getDate().toString();
    
    // 补零确保格式一致
    if (month.length < 2) {
      month = '0' + month;
    }
    if (day.length < 2) {
      day = '0' + day;
    }
    
    console.log('year:', year);
    console.log('month:', month);
    console.log('day:', day);
    const param1 = {
      date: year + month + day,
      companyId: username,
    };
    const param2 = {
      date: year + month,
      companyId: username,
    };
    const param3 = {
      date: year,
      companyId: username,
    };
    defHttp
      .post(
        {
          url: '/ddyht/jxcInventory/getamount',
          params: param1,
        },
        { successMessageMode: 'none' }
      )
      .then((res) => {
        console.log('res', res);
      });
    defHttp
      .post(
        {
          url: '/ddyht/jxcInventory/getyueamount',
          params: param2,
        },
        { successMessageMode: 'none' }
      )
      .then((res) => {
        console.log('res', res);
      });
    defHttp
      .post(
        {
          url: '/ddyht/jxcInventory/getnianamount',
          params: param3,
        },
        { successMessageMode: 'none' }
      )
      .then((res) => {
        console.log('res', res);
      });
    defHttp
      .get(
        {
          url: '/ddyht/jxcInventory/tz',
          params: { username: username },
        },
        { successMessageMode: 'none' }
      )
      .then((res) => {
        console.log('res', res);
        url.value = res;
        // window.open(url.value, '_blank');
      });
  });
</script>
